<?php

namespace Database\Seeders;

use App\Models\Admin;
use App\Models\Article;
use Illuminate\Database\Seeder;

class ArticleSeeder extends Seeder
{

    public function run()
    {

        $configs =
            [
                [
                    "name" => "title",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "标题",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => "请输入标题",
                    "validate_rule" => null
                ],
                [
                    "name" => "description",
                    "rank" => 0,
                    "show" => true,
                    "type" => "textarea",
                    "title" => "文章简介",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "preview",
                    "rank" => 0,
                    "show" => true,
                    "type" => "image",
                    "title" => "缩略图",
                    "value" => null,
                    "system" => false,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "images",
                    "rank" => 0,
                    "show" => true,
                    "type" => "images",
                    "title" => "图集",
                    "value" => null,
                    "system" => false,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "content",
                    "rank" => 0,
                    "show" => true,
                    "type" => "editor",
                    "title" => "正文",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => "请输入文本内容",
                    "validate_rule" => null
                ],
                [
                    "name" => "url",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "跳转链接",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => "站点跳转链接",
                    "validate_rule" => null
                ],
                [
                    "name" => "source",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "来源",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => "请输入文章来源",
                    "validate_rule" => null
                ],
                [
                    "name" => "click",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "查看次数",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "author",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "文章作者",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "template",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "文章显示模板",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "keywords",
                    "rank" => 0,
                    "show" => true,
                    "type" => "input",
                    "title" => "内容关键字",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ],
                [
                    "name" => "recommend",
                    "rank" => 0,
                    "show" => true,
                    "type" => "radio",
                    "title" => "是否推荐",
                    "value" => null,
                    "system" => true,
                    "options" => null,
                    "placeholder" => null,
                    "validate_rule" => null
                ]
            ];
        $articles = [
            ['title' => '房屋租售', 'fields' => $configs],
            ['title' => '二手转让', 'fields' => $configs],
            ['title' => '车辆买卖', 'fields' => $configs],
            ['title' => '宠物', 'fields' => $configs],
            ['title' => '公告', 'fields' => $configs],
            ['title' => '广告', 'fields' => $configs],
        ];

        foreach ($articles as $article) {
            Article::create($article);
        }
    }
}
